<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>汇率计算</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
    <style type="text/css">
    html,
    body {
        height: 100%;
    }

    #wrap {
        height: 100%;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-orient: vertical;
        -webkit-flex-flow: column;
        flex-flow: column;
    }

    #header {
        background: #fbdb0a;
        color: #000;
    }

    #main {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        flex: 1;
    }

    .menu {
        box-sizing: border-box;
        padding-bottom: 5px;
        padding-top: 32px;
        color: #585858;
        background-size: 22px 22px;
        background-position: center 8px;
        background-repeat: no-repeat;
    }

    .home {
        background-image: url(../../image/footer/one.png);
    }

    .video {
        background-image: url(../../image/footer/two.png);
    }

    .gambit {
        background-image: url(../../image/footer/three.png);
    }

    .my {
        background-image: url(../../image/footer/four.png);
    }

    .home.active {
        background-image: url(../../image/footer/one_act.png);
    }

    .video.active {
        background-image: url(../../image/footer/two_act.png);
    }

    .gambit.active {
        background-image: url(../../image/footer/three_act.png);
    }

    .my.active {
        background-image: url(../../image/footer/four_act.png);
    }

    #footer {
        background-color: #fff;
        width: 100%;
        text-align: center;
        border-top: #b2b2b2 solid 0.5px;
        color: #646464;
    }
    </style>
</head>

<body>
    <div id="wrap">
        <header id="header" class="aui-bar aui-bar-nav">{{text}}</header>
        <div id="main" class="flex-con"></div>
        <footer class="aui-bar aui-bar-tab" id="footer">
            <div class="aui-bar-tab-item home menu" tapmode v-for="(item, index) in menu" :key="index" :class="[item.class,{'active': activeId == item.id}]" @click="goMenu(item)">
                <div class="aui-bar-tab-label">{{item.text}}</div>
            </div>
        </footer>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
apiready = function() {
    init()
    api.refreshHeaderLoadDone()
    // 再点一次退出应用
    api.setStatusBarStyle({
        style: 'dark'
    });
    api.addEventListener({
        name: 'keyback'
    }, function(ret, err) {
        api.toast({
            msg: '再点一次退出应用',
            duration: 2000,
            location: 'bottom'
        });
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWidget({
                silent: true
            });
        });
        setTimeout(function() {
            exitApp();
        }, 2000)
    });
    var vm = new Vue({
    el: '#wrap',
    data: {
        text: "汇率换算",
        activeId: '0',
        menu: [
            { id: '0', text: '汇率换算', link: 'index.html', class: 'home', active: true },
            { id: '1', text: '个人中心', link: 'personal.html', class: 'video', active: false }
        ],
        rataData: [
            { zh: '人民币', en: 'CNY', isSelect: '已选', rate: '1', value: '' },
            { zh: '美元', en: 'USD', isSelect: '已选', rate: '0.1439', value: '' },
            { zh: '港元', en: 'HKD', isSelect: '已选', rate: '1.1281', value: '' },
            { zh: '日元', en: 'JPY', isSelect: '', rate: '16.0924', value: '' },
            { zh: '英镑', en: 'GBP', isSelect: '', rate: '0.1121', value: '' },
            { zh: '欧元', en: 'EUR', isSelect: '', rate: '0.1263', value: '' }
        ]
    },
    methods: {
        // 切换底部页面
        goMenu: function(item) {
            item.active = true
            this.activeId = item.id
            this.text = item.text
            api.openFrame({
                name: 'index',
                url: item.link,
                bounces: true,
                rect: {
                    x: 0,
                    y: headerPos.h,
                    w: 'auto',
                    h: mainPos.h - footerPos.h
                }
            });
        }
    },
    mounted: function() {
        var rataData = $api.getStorage('rataData')
        // $api.confirm(api.pageParam.rataData)
        if (rataData) {

        } else {
            $api.setStorage('rataData',this.rataData)
        }
    }
})
};

var header, headerPos, main, mainPos, footer, footerPos

function init() {
    header = $api.byId('header');
    //适配iOS 7+，Android 4.4+状态栏
    $api.fixStatusBar(header);
    headerPos = $api.offset(header);
    main = $api.byId('main');
    mainPos = $api.offset(main);
    footer = $api.byId('footer');
    footerPos = $api.offset(footer);
    api.openFrame({
        name: 'index',
        url: 'index.html',
        bounces: true,
        rect: {
            x: 0,
            y: headerPos.h,
            w: 'auto',
            h: mainPos.h - footerPos.h
        }
    });
}


// 再点一次退出应用
function exitApp() {
    api.addEventListener({
        name: 'keyback'
    }, function(ret, err) {
        api.toast({
            msg: '再点一次退出应用',
            duration: 2000,
            location: 'bottom'
        });
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWidget({
                silent: true
            });
        });
        setTimeout(function() {
            exitApp();
        }, 2000)
    });

}


</script>

</html>